<template>
  <common-card title="今日销售额" :value="numberFormat(salesToday)">
    <template #default >
      <div class="compare">
        <div class="emphasis">
          <span>日同比</span>
          <span class="emphasis">{{numberFormat(salesGrowthLastDay)}}%</span>
          <span class="decrement"></span>
        </div>
        <div class="emphasis">
          <span>月同比</span>
          <span class="emphasis">{{numberFormat(salesGrowthLastMonth)}}%</span>
          <span class="increment"></span>
        </div>
      </div>
    </template>
    <template #foot>
      <span>昨日销售额</span>
      <span class="emphasis">{{moneyFormat(salesLastDay)}}</span>
    </template>
  </common-card>
</template>

<script lang="ts">
import CommonCard from './CommonCard.vue'
export default {
  name: 'TodaySale',
  components: {
    CommonCard
}
}
</script>

<script lang="ts" setup>
import {ref,computed} from 'vue'
import { useReportDataStore } from '@/stores/reportData'
import useFormat from '@/hooks/useFormat'
const { numberFormat, moneyFormat } = useFormat()
// 获取store实例
const reportDataStore = useReportDataStore()

// 1. 今日销售额
const salesToday = computed(() => reportDataStore.reportData.salesToday)
// 2. 日同比
const salesGrowthLastDay = computed(()=>reportDataStore.reportData.salesGrowthLastDay)
// 3. 月同比
const salesGrowthLastMonth = computed(()=>reportDataStore.reportData.salesGrowthLastMonth)
// 4. 昨日销售额
const salesLastDay = computed(()=>reportDataStore.reportData.salesLastDay)
</script>

<style lang="scss" scoped>
.compare {
  height: 100%;
  .emphasis {
    display: flex;
    align-items: center;
  }
}
</style>